package cn.bugstack.chatgpt.data.domain.openai.model.aggregates;

import cn.bugstack.chatgpt.data.domain.openai.model.entity.MessageEntity;
import cn.bugstack.chatgpt.data.types.common.Constants;
import cn.bugstack.chatgpt.data.types.enums.ChatGPTModel;
import cn.bugstack.chatgpt.data.types.enums.OpenAiChannel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @author Fuzhengwei bugstack.cn @小傅哥
 * @description
 * @create 2023-07-22 21:09
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ChatProcessAggregate {

    /** 验证信息 */
    private String token;
    /** 用户id */
    private String openid;
    /** 默认模型 */
    private String model = ChatGPTModel.GPT_3_5_TURBO.getCode();
    /** 问题描述 */
    private List<MessageEntity> messages;

    public  boolean isWhiteList(String whiteListStr){
        //把注入的白名单数组拆分成字符串进行比对
        String[] whiteList = whiteListStr.split(Constants.SPLIT);
        for (String whiteOpenid:whiteList){
            if (whiteOpenid.equals(openid)) return true;


        }
        // 若不是白名单，则返回false
        return false;

    }
    public OpenAiChannel getChannel(){
        return OpenAiChannel.getChannel(this.model);
    }


}
